package com.ccys.common.constants;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class ContextConstants {
    /**
     * 常量
     */
    public static final String PROJECT_NAME = "ccys";
    public static final String PROJECT_CN_NAME = "基础项目中文别名";
    public static final String MODEL_DESC = "获取成功。swagger请点击model查看注释\r\ndoc请直接查看下列响应参数";
    public static final String DESC_411 = "请求不合法(接口验证失败)";

    public static final String DEFAULT_PWD = "123456";
    public static final String APP_NAME = "WhiteCoat";

    /**
     * 默认未操作时间 默认15分过期
     */
    public static final int DEFAULT_NOT_OPERATED_TIME = 60*15;

    /**
     * 十分钟之后过期
     */
    public static final int TEN_MINUTE_EXPIRATION = 60*10;


    /**
     * 病人端  token 默认到期时间  1 年=31536000 秒
     */
    public static final Long DEFAULT_PATIENT_EXPIRES_TIME = 60*60*24*365L;
    /**
     * 获取换行符 windows系统为\r\n，Linux系统为\n 默认为\n
     */
    public static final String LINE_SEPARATOR = System.getProperty("line.separator", "\n");

    public static final String TEST_ACCOUNT = "testAccount";

    public static final String IOS_JPUSH_PRODUCTION_ENVIRONMENT = "iosJPushProductionEnvironment";


    //配置环境
    public static String PROFILES_ACTIVE;

    //redis路径
    public static String REDIS_HOST;

    //redis端口
    public static Integer REDIS_PORT;

    //redis密码
    public static String REDIS_PASSWORD;

    //服务context-path
    public static String SERVER_PATH;

    //swagger参数校验
    public static Boolean PARAM_VALID;

    /**
     * 回调地址
     */
    public static String callbackAddress;

    //应用名称，作为服务id
    public static String APPLICATION_NAME;


    @Value("${callbackAddress:}")
    private String callbackAddr;

    @Value("${swagger.param-valid.enable}")
    public void setParamValid(Boolean paramValid) {
        PARAM_VALID = paramValid;
    }

    @Value("${server.servlet.context-path}")
    public void setServerPath(String serverPath) {
        SERVER_PATH = "/".equals(serverPath) ? "" : serverPath;
    }

    @Value("${spring.profiles.active}")
    public void setProfilesActive(String profilesActive) {
        PROFILES_ACTIVE = profilesActive;
    }

    @Value("${spring.redis.host}")
    public void setRedisHost(String redisHost) {
        REDIS_HOST = redisHost;
    }

    @Value("${spring.redis.port}")
    public void setRedisPort(Integer redisPort) {
        REDIS_PORT = redisPort;
    }

    @Value("${spring.redis.password}")
    public void setRedisPassword(String redisPassword) {
        REDIS_PASSWORD = redisPassword;
    }

    @Value("${spring.application.name}")
    public void setApplicationName(String applicationName) {
        APPLICATION_NAME = applicationName;
    }


}
